﻿
Partial Class Staff
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        General.FilterBySquadron(sqldsStaff, ListBox1)
    End Sub

    Protected Sub btnInsert_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnInsert.Click
        GridView1.ShowFooter = True
        General.FilterBySquadron(sqldsStaff, ListBox1)
        'General.FilterBySquadron(sqldsSquadrons, ListBox1)
        'sqldsStaff.Insert()
    End Sub

    Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
        'General.FilterBySquadron(sqldsStaff, ListBox1)
        'Response.Write(e.CommandName)
        Select Case e.CommandName
            Case "New"
                For Each x As WebControls.Parameter In sqldsStaff.InsertParameters
                    Dim ctrl As Web.UI.Control
                    Dim value As String = ""

                    ctrl = GridView1.FooterRow.FindControl("txt" & x.Name)
                    If ctrl IsNot Nothing Then value = CType(ctrl, TextBox).Text
                    ctrl = GridView1.FooterRow.FindControl("ddl" & x.Name)
                    If ctrl IsNot Nothing Then value = CType(ctrl, DropDownList).SelectedValue
                    If value <> "" Then x.DefaultValue = value
                Next
                sqldsStaff.Insert()
                General.FilterBySquadron(sqldsStaff, ListBox1)
                GridView1.ShowFooter = False
            Case "CancelNew"
                General.FilterBySquadron(sqldsStaff, ListBox1)
                GridView1.ShowFooter = False
            Case "Edit", "Cancel"
                General.FilterBySquadron(sqldsStaff, ListBox1)
        End Select
    End Sub

End Class
